﻿@{var currentEnterprise = Session["SELECTED-ENTERPRISE"] as SecurityApi.Model.Enterprise; }

<br />
<h4>ENTERPRISE USERS: @currentEnterprise.Title</h4>

@(Html.Kendo().Grid<SecurityApi.Model.EnterpriseUser>()
    .Name("Grid")
    .HtmlAttributes(new { style = "height:500px;" })
    .Columns(columns =>
    {

        //If your grid is ajax bound. You should also define a ClientTemplate for all template columns:
        columns.Template(@<text>
                    @Html.ActionLink("Manage", "SelectUser", "User", new { userId = @item.UserId })  
                    </text>)
                    .ClientTemplate("<a href='" + Url.Content("~/User/SelectUser/?") + "userId= #= UserId #'" + ">Manage</a>") //always use Url.Content to get the correct relative path
                    .Title("Manage").Width(100);

        columns.Bound(c => c.UserId).Width(100);

        columns.Bound(c => c.UserName);
        columns.Bound(c => c.Enterprise.Name).Title("Enterprise");

    })
    .Pageable()
    .Sortable()
    .Selectable()
    .Resizable(resize => resize.Columns(true))
    .Reorderable(reorder => reorder.Columns(true))
    .Filterable()
    .Scrollable()
    .DataSource(dataSource => dataSource
        .Ajax()
        .PageSize(50)
        .Model(model => model.Id(p => p.UserId))
        .Read(read => read.Action("AjaxGetEnterpriseUsers", "User", new {enterpriseId=currentEnterprise.Id }))
    )
)
